package com.win.oauth.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;


public class PathUtil {

    public static boolean match(String patternPath, String requestPath) {
        if (StringUtils.isBlank(patternPath) || StringUtils.isBlank(requestPath)) {
            return false;
        }
        PathMatcher matcher = new AntPathMatcher();
        return matcher.match(patternPath, requestPath);
    }

    public static void main(String[] args) {
        long l = System.currentTimeMillis();
        System.err.println(PathUtil.match("/oauth/*", "/oauth/user"));
        System.err.println(PathUtil.match("/oauth*/{xxx}", "/oauth2222/user"));
        System.err.println(PathUtil.match("/oauth/**", "/oauth/user/12"));
        System.err.println(System.currentTimeMillis() - l);
    }
}
